var POLE_STARTING_Y = 0;
var POLE_HEIGHT = 400;
var BUCKET_HEIGHT = 100;
var BUCKET_POINTS = 200;
var ATTEMPT_BONUS_POINTS = 700;

function Game(){
	this.score = 0;
	this.level = 1;
	this.attempts = 5;
	this.bucketHeights = new Array();
}

//Reset function that resets all the values back to their original numbers.
Game.prototype.resetGame = function(){
	this.score = 0;
	this.level = 1;
	this.attempts = 3;
	this.bucketHeights = new Array();
}

//Playing field for the level that the user is currently on.
//Afterwards, the game will be drawn onto the canvas.

Game.prototype.setGameLevel = function(){
	var numberOfbuckets = this.getNumberOfbuckets();
	this.bucketHeights = new Array( numberOfbuckets );
	this.setAttempts( this.getNumberOfAttempts() );
	var numberOfIntervals = Math.floor( ( POLE_HEIGHT - BUCKET_HEIGHT * 2 ) / BUCKET_HEIGHT );
	for( i = 0; i < numberOfbuckets; i = i + 1 ){
		var height = Math.floor( Math.random() * numberOfIntervals ) * BUCKET_HEIGHT + POLE_STARTING_Y + BUCKET_HEIGHT;
		this.bucketHeights[ i ] = height;
	}
}

//Calculates the number of POLE lines and buckets available on the field at a certain level.
Game.prototype.getNumberOfbuckets = function (){
	//For the first level, there will be 1 bucket.
	if( this.level == 1 ){
		return 1;
	}

	//For the second level, there will be 2 bucket.
	else if( this.level == 2 ){
		return 2;
	}

	//For the third level, there will be 3 buckets.
	else if( this.level == 3){
		return 3;
	}

}

//Calculates the number of attempts to launch the astronaut given for each level.

Game.prototype.getNumberOfAttempts = function(){
//For the first level, with only 1 bucket, there will be 5 attempts
//for practice

	if( this.level == 1 ){
		return 5;
	}

	//For the second level, with 3 buckets, there will be 6 attempts
	//to make it a bit more challenging.

	if( this.level == 2 ){
		return 6;
	}

	//For the third level, with 5 buckets, there will be 7 attempts
	//to make it more difficult.

	if( this.level == 3 ){
		return 7;
	}

}

//Return the score function
Game.prototype.getScore = function(){
	return this.score;
}

//Sets the score function
Game.prototype.setScore = function( score ){
	this.score = score;
}

//Return the level function
Game.prototype.getLevel = function(){
	return this.level;
}

//Sets the level function
Game.prototype.setLevel = function( level ){
	this.level = level;
}

//Return the number of attempts function
Game.prototype.getAttempts = function(){
	return this.attempts;
}

//Sets the number of attempts function
Game.prototype.setAttempts = function( attempts ){
	this.attempts = attempts;
}

//Return the buckets heights function
Game.prototype.getbucketHeights = function(){
	return this.bucketHeights;
}

